<?php
// +---------------------------------------------------------------------+
// | OneBase    | [ WE CAN DO IT JUST THINK ]                            |
// +---------------------------------------------------------------------+
// | Licensed   | http://www.apache.org/licenses/LICENSE-2.0 )           |
// +---------------------------------------------------------------------+
// | Author     | Bigotry <3162875@qq.com>                               |
// +---------------------------------------------------------------------+
// | Repository | https://gitee.com/Bigotry/OneBase                      |
// +---------------------------------------------------------------------+

namespace app\common\model;


/**
 * Currency模型
 */
class WalletRechargeType extends ModelBase
{

    protected $insert = ['create_time'];

    /**
     * 连货币表
     */
    public function currency(){
            return $this->belongsTo('Wallet','currency_id','id');
    }


    /**
     * 时间自动完成
     */
    public function setCreateTimeAttr()
    {

        return TIME_NOW;
    }

    /**
     * 获取器
     */
    public function getCurrencyNameAttr()
    {

        return $this->currency()->where('id',$this->currency_id)->value('name');
    }

    public function getStateTextAttr()
    {

        $status = [ 2 => "<span class='badge bg-red'>禁用</span>", 1 => "<span class='badge bg-green'>启用</span>"];

        return $status[$this->state];
    }

    /**
     * 二维码
     */
    public function getImageAttr()
    {
        return get_picture_url($this->cover_id,false);
    }
}
